let path = require('path');
let getUserInfo = require(path.join(__dirname,'getUserInfo'));
const checkLogin = function(req,res,next){
    let userId = req.cookies.userId;
    let userInfo = getUserInfo.getUserInfo(userId);
    if(userInfo){
        req.body.userInfo = userInfo;
        next();
    }else{
        res.redirect('/login');
    }
}

module.exports = checkLogin;